<!--

生成最基本的Restful模板页面

顶部有按（门店、时间段*）查询 添加按钮

包含一个 ag-grid 列表，默认表头只有一行，每列都可查询，默认每条最后有打开、删除按钮

有新增、修改弹出层
-->

<div class="view-header">
    <div class="view-header-left">
        <div ng-show="!add_cover&&!insurance_cover&&!place_order_open">
            <div class="search-shop">
                <i class="fa fa-home"></i>
                <shop-picker class="from-control" shop="search_shop"></shop-picker>
            </div>

            <div class="search-date">
                <i class="fa fa-calendar search-date-i"></i>
                <datetimepicker class="search-date-start"
                                min-view="2"
                                end-date="search_params.date_end"
                                ng-model="search_params.date_start"></datetimepicker>

            </div>
            <div class="search-date">
                <i class="fa fa-calendar search-date-i"></i>
                <datetimepicker class="search-date-end"
                                min-view="2"
                                start-date="search_params.date_start"
                                ng-model="search_params.date_end"></datetimepicker>
            </div>
        </div>
        <div class="view-header-left">
            <!-- 查询 -->
            <div class="view-header-item no-widen"
                 ng-show = "!place_order_open&&!add_cover"
                 ng-click="refresh()" title="查询" >
                <i class="fa fa-search"></i>
            </div>
            <div class="view-header-item color-open"
                 ng-show = "selected_visit !== undefined && !place_order_open&&!add_cover"
                 ng-click="open_place_order()" title="新增订单" >
                <i class="fa fa-plus"></i> 新增订单
            </div>

            <!-- ORDER -->
            <div class="view-header-item color-open above-cover no-widen"
                 ng-show = "place_order_open"
                 ng-click= "close_place_order()" title="关闭" >
                <i class="fa fa-close"></i>
            </div>

            <div class="view-header-item color-check above-cover no-widen"
                 ng-show = "place_order_open"
                 ng-click= "submit_order()" title="提交" >
                <i class="fa fa-upload"></i>
            </div>

        </div>
    </div>
</div>
<div class="view-content ">
        <div ag-grid="grid_visit" class="ag-material drag-top"
             style="height :50%"></div>
             <div class="drag"><span class="fa fa-navicon"></span></div>
        <div ag-grid="grid_order" class="ag-material drag-bottom"
             style="height :calc(50% - 20px);"></div>

</div>

<!-- 新增订单弹出界面 -->
<div class="data-overlay" ng-show = 'place_order_open'>
    <div class="overlay-container">
        <div class="overlay-header">添加订单</div>
        <div ng-form name="reception_add" novalidate="novalidate">
            <div class="overlay-content">
                <div class="overlay-column overlay-column-3">
                    <div class="overlay-item">
                        <span class="overlay-name">日期</span>
                        <input type="text" value="{{selected_visit.arrive_time | date:'yyyy-MM-dd'}}" disabled>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">到店时间</span>
                        <datetimepicker ng-model="selected_visit.arrive_time"
                                        format="hh:ii"
                                        start-view="1"
                                        max-view="1"

                                        title="false"
                                ></datetimepicker>
                    </div>

                    <div class="overlay-item">
                        <span class="overlay-name">离店时间</span>
                        <datetimepicker ng-model="selected_visit.exit_time"
                                        name = "exit_time"
                                        format="hh:ii"
                                        start-view="1"
                                        max-view="1"
                                        title="false"
                                        start-date="selected_visit.arrive_time"
                                        ng-required = "(selected_visit.entrance_type == '1' || selected_visit.entrance_type == '2' || selected_visit.entrance_type == '6')"
                                ></datetimepicker>

                    </div>

                    <div class="overlay-item">
                        <span class="overlay-name">顾问（潜客）</span>
                        <input type = "text" ng-model="selected_visit.owner_id">
                    </div>

                    <div class="overlay-item">
                        <span class="overlay-name">顾问（流量）</span>
                        <input type = "text" ng-model="selected_visit.salesman_name">
                    </div>

                    <div class="overlay-item">
                        <span class="overlay-name">销售门店</span>
                        <input type="text"
                               ng-model="selected_visit.sales_shop_name"
                               disabled>
                    </div>
                </div>
                <div class="overlay-column overlay-column-3">
                    <div class="overlay-item">
                        <span class="overlay-name">姓名</span>
                        <input type="text"
                               placeholder="name" ng-model="selected_visit.name">
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">性别</span>
                        <select ng-model="selected_visit.sex">
                            <option value="1">男</option>
                            <option value="2">女</option>
                        </select>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">联系电话</span>
                        <input type="text" ng-model="selected_visit.phone"
                               name = "phone"
                               ng-blur="phone_blur(selected_visit,selected_visit.phone)"
                               ng-pattern = "/^[0-9]{11}$/"
                               ng-required = "selected_visit.entrance_type != '3' && selected_visit.entrance_type != '1' ">
                        <p ng-show = "reception_add.phone.$invalid" class="overlay-item-bottom">
                            客户的联系电话，潜客的唯一标记ID，只有下列情况可以不填:
                            <br> * 首次进入
                            <br> * 非购车
                            <br> ，其他情况必须是<i>11位合法的手机号码</i>
                        </p>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">兴趣爱好</span>
                        <input type="text" ng-model="selected_visit.habit">
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">客户区域</span>
                        <select ng-model="selected_visit.region">
                            <option value="新区">新区</option>
                            <option value="姑苏">姑苏</option>
                            <option value="园区">园区</option>
                            <option value="相城">相城</option>
                            <option value="吴中">吴中</option>
                            <option value="吴江">吴江</option>
                            <option value="常熟">常熟</option>
                            <option value="外区">外区</option>
                        </select>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">来源</span>
                        <select ng-model="selected_visit.source">
                            <option value="1">路过</option>
                            <option value="2">网络</option>
                            <option value="3">广电</option>
                            <option value="4">基盘</option>
                            <option value="5">活动</option>
                            <option value="6">介绍</option>
                        </select>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">试乘试驾</span>
                        <select ng-model="selected_visit.is_test_drive">
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>

                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">购买性质</span>
                        <select ng-model="selected_visit.replacement_assessment"
                                ng-required = "true"
                                name = "replacement_assessment" >

                            <option value="0">首购</option>
                            <option value="1">增购</option>
                            <option value="2">换购</option>
                            <!-- <option value="3">评估</option> -->
                        </select>
                    </div>
                    <div class="overlay-item">
                        <span class="overlay-name">接触方式</span>
                        <select ng-model="selected_visit.meeting_type"
                                name="meeting_type"
                                ng-change="meeting_type_change()"
                                ng-required = "true" >
                            <option value="showroom">展厅</option>
                            <option value="dcc">DCC</option>
                        </select>
                    </div>
                    <div class="overlay-item" ng-show="selected_visit.meeting_type=='showroom'">
                        <span class="overlay-name">接触性质</span>
                        <select ng-model="selected_visit.entrance_type"
                                name="entrance_type"
                                ng-required="selected_visit.meeting_type=='showroom'">
                            <option value="1">首次进入</option>
                            <option value="2">再次进入</option>
                            <option value="4">订单后</option>
                            <option value="3">非购车用户</option>
                        </select>
                    </div>
                    <div class="overlay-item" ng-show="selected_visit.meeting_type=='dcc'">
                        <span class="overlay-name">接触性质</span>
                        <select ng-model="selected_visit.entrance_type" ng-required="selected_visit.meeting_type=='dcc'" name="entrance_type_dcc">
                            <option value="5">在途</option>
                            <option value="6">邀约到店</option>
                            <option value="2">再次进入</option>
                            <option value="4">订单后</option>
                        </select>
                    </div>
                </div>

                <div class="overlay-column overlay-column-3">
                    <div class="overlay-item">
                        <span class="overlay-name">客户级别</span>
                        <select ng-model="selected_visit.customer_level" disabled>
                            <option value=""></option>
                            <option value="O" ng-show="selected_visit.entrance_type != 5">O (订单)</option>
                            <option value="H">H (一周内）</option>
                            <option value="A">A (二周内）</option>
                            <option value="B">B (一个月）</option>
                            <option value="C">C (二个月）</option>
                            <option value="N">N (首次接触）</option>
                        </select>
                    </div>
                    <div class="reception-vehicle overlay-column-border"
                         ng-show="selected_visit.customer_level =='O'"
                            >
                        <div class="reception-vehicle-block clearfix"
                             ng-repeat="ov in order_vehicles">
                            <div class="overlay-item">
                                <span class="overlay-name">订单车型</span>
                                <vm-selector ng-if="!validate_role('V_ORDER_CREATE_VEHICLE_MODEL_FREE_EDIT')"
                                             vehicle-model="ov.v" ></vm-selector>
                                <vm-input ng-if="validate_role('V_ORDER_CREATE_VEHICLE_MODEL_FREE_EDIT')"
                                        ng-model="ov.v" msrp="true"></vm-input>
                            </div>

                            <div class="overlay-item">
                                <span class="overlay-name">数量</span>
                                <input type="number"
                                       min='1'
                                       ng-model="ov.amount">
                            </div>

                            <div class="overlay-item">
                                <span class="overlay-name">颜色</span>
                                <input class="" type="text"
                                       ng-model="ov.color">
                            </div>

                            <div class="overlay-item">
                                <span class="overlay-name">
                                    贷款
                                </span>
                                <div class="overlay-item-insurance">
                                    <label>
                                        <input type="checkbox" ng-model="ov.loan"
                                               ng-true-value="1" ng-false-value="0">
                                    </label>
                                </div>

                            </div>

                            <span ng-show="order_vehicles.indexOf(ov) !== 0"
                                  class="close"
                                  ng-click="order_vehicle_del(ov)"
                                    >
                                <i class="fa fa-trash-o"></i>
                            </span>
                        </div>

                        <!-- <div class="overlay-item">
                            <p class="add line"
                               style="color:#fff;background: #eee; border: 1px #ccc solid;cursor: pointer"
                               ng-click="order_vehicle_new()"> 添加车型 </p>
                        </div> -->

                        <div style="color:red" class="overlay-item">
                            <p >
                                注意：
                                <br/>
                                同种车型请正确填写数量,
                                一条订单可以含有任意数量的同种车型,
                                <br/>
                                但是不同种类的车型请点击“添加车型”来添加多条订单。
                            </p>

                            <p>
                            </p>
                        </div>
                    </div>

                    <!-- div class="overlay-item" ng-show="selected_visit.customer_level !='O'">
                        <span class="overlay-name">意向车型</span>
                    </div -->

                </div>
            </div>
            <div class=" overlay-item help-doc" ng-show="toggle_help"></div>
        </div><!--forM-->
    </div>
</div>


<!-- 填写结算单 add增加结算单-->
<!--startprint-->


<script type="text/javascript">
$(document).ready(function() {

        $(document).on('mousedown','.drag',function(e){
            e.preventDefault();
            var drag_t = e.pageY;
            var drag_top = $('.drag-top');
            var drag_bottom = $('.drag-bottom');
            var b_h = drag_bottom.height();
            var t_h = drag_top.height();

            $(document).mousemove(function(e){
                var t = e.pageY;

                if (t <= drag_t) {
                    
                    var p = drag_t - e.pageY;

                    drag_bottom.height(b_h + p);
                    drag_top.height(t_h - p);

                }else if(t > drag_t){
                    var e = e.pageY - drag_t;

                    drag_bottom.height(b_h - e);
                    drag_top.height(t_h + e);
                }
            });
        });
        $(document).on('mouseup',function(){
            $(this).unbind('mousemove');
        });
    
});
</script>